﻿@{
    Layout = "_Layout.cshtml";
}
@using WebApp.Models
@using WebApp.Extensions
@using Telerik.Web.Mvc.UI
@model IEnumerable<ENT_Gruppo>
@{
    ViewBag.Title = "Lista delle famiglie di piatti";
}
@(Html.Telerik().Grid(Model)
        .Name("Grid")
        .ToolBar(commands => commands.Insert())
        .DataKeys(keys => keys.Add(c => c.Guid))
        .HtmlAttributes(new { @class = "data" })
        .Columns(columns =>
        {
            columns.Bound(o => o.Nome).Sortable(true).Title("Nome");
            columns.Bound(o => o.Breve).Sortable(true).Title("Nome");
            columns.Template(o => o.Disponibile.Render()).Title("Disponibile").Width(50);
            columns.Template(o => @Html.ActionLink("Aggiunte", "FAM_ING_LST", new { f0 = o.Guid })).Width(80);
            columns.Template(o => @Html.ActionLink("Piatti", "FAM_PIA_LST", new { f0 = o.Guid })).Width(80);
            columns.Command(commands =>
            {
                commands.Edit().ButtonType(GridButtonType.Image);
                commands.Delete().ButtonType(GridButtonType.Image);
            }).Width(100);
        })
        .Sortable(sorting => sorting.OrderBy(x => x.Add(y => y.Nome)))
        .Editable(editing => editing.Mode(GridEditMode.PopUp))
        .DataBinding(dataBinding => dataBinding
            .Server()
               .Select("FAM_LST", "Setup")
               .Insert("FAM_INS", "Setup")
               .Update("FAM_SAV", "Setup")
               .Delete("FAM_DEL", "Setup"))

)